﻿Public Class Informe1
    Inherits System.Web.UI.Page
    Private strCalDesde, strCalHasta As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try
            If Not IsPostBack Then
                Var_Globales.Setea_paginas("Informe1.aspx")
                FG.CargaCombo("traerVacunas", cboCriterioTop)
            Else
                If Request.Form("__EVENTTARGET") = "FechaDesde" Then
                    txtCalDesde.Text = Request.Form("__EVENTARGUMENT")
                    strCalDesde = txtCalDesde.Text
                End If
                If Request.Form("__EVENTTARGET") = "FechaHasta" Then
                    txtCalHasta.Text = Request.Form("__EVENTARGUMENT")
                    strCalHasta = txtCalHasta.Text
                End If
            End If
        Catch ex As Exception
        End Try

    End Sub



    Protected Sub btnGenerar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGenerar.Click

        Dim i As Integer

        Dim param(2) As ADODB.Parameter
        Dim Rs As ADODB.Recordset

        param(0) = New ADODB.Parameter
        param(0).Name = "@vacuna"
        param(0).Type = ADODB.DataTypeEnum.adVarChar
        param(0).Direction = ADODB.ParameterDirectionEnum.adParamInput
        param(0).Value = cboCriterioTop.Text
        param(0).Size = 20

        param(1) = New ADODB.Parameter
        param(1).Name = "@RangoDesde"
        param(1).Type = ADODB.DataTypeEnum.adDate '<--campo fecha
        param(1).Direction = ADODB.ParameterDirectionEnum.adParamInput
        param(1).Value = "1/10/2013"

        param(2) = New ADODB.Parameter
        param(2).Name = "@RangoDesde"
        param(2).Type = ADODB.DataTypeEnum.adDate '<--campo fecha
        param(2).Direction = ADODB.ParameterDirectionEnum.adParamInput
        param(2).Value = "10/11/2013"


        Rs = Datos.TraerTodos("Trae_PorcentajeDeVacunadosXVacunaYfecha", param, "Informe1.aspx")

        Me.pnlrdos.Visible = "true"

        Rs.MoveFirst()

        'ESTO ES UN MODELO PARA LOS INFORMES, LUEGO CON INFO REAL VEMOS!!!
        Dim sb1 As New StringBuilder
        Dim sb2 As New StringBuilder
        Dim sb3 As New StringBuilder

        For i = 1 To Rs.RecordCount
            If i <= 3 Then
                'nomPcia = Rs.Fields(0).Value
                If i = 1 Then
                    lblPcia1.Visible = True
                    lblPcia1.Text = Rs.Fields(0).Value.ToString
                    imgPcia1.Visible = True
                    imgPcia1.ImageUrl = "~/Imagenes/Provincias/" & Replace(Rs.Fields(0).Value.ToString, " ", "") & "Blue.png"
                    sb1.AppendLine(Rs.Fields(0).Value.ToString)
                    sb1.AppendLine(Rs.Fields(1).Value.ToString & " pacientes vacunados contra la hepatitis B")
                    sb1.AppendLine("Total: " & Rs.Fields(2).Value.ToString & " %")
                    Me.imgPcia1.ToolTip = sb1.ToString
                ElseIf i = 2 Then
                    lblPcia2.Visible = True
                    lblPcia2.Text = Rs.Fields(0).Value.ToString
                    imgPcia2.Visible = True
                    imgPcia2.ImageUrl = "~/Imagenes/Provincias/" & Replace(Rs.Fields(0).Value.ToString, " ", "") & "Blue.png"
                    sb2.AppendLine(Rs.Fields(0).Value.ToString)
                    sb2.AppendLine(Rs.Fields(1).Value.ToString & " pacientes vacunados contra la hepatitis B")
                    sb2.AppendLine("Total: " & Rs.Fields(2).Value.ToString & " %")
                    Me.imgPcia2.ToolTip = sb2.ToString
                Else
                    lblPcia3.Visible = True
                    lblPcia3.Text = Rs.Fields(0).Value.ToString
                    imgPcia3.Visible = True
                    imgPcia3.ImageUrl = "~/Imagenes/Provincias/" & Replace(Rs.Fields(0).Value.ToString, " ", "") & "Blue.png"
                    sb3.AppendLine(Rs.Fields(0).Value.ToString)
                    sb3.AppendLine(Rs.Fields(1).Value.ToString & " pacientes vacunados contra la hepatitis B")
                    sb3.AppendLine("Total: " & Rs.Fields(2).Value.ToString & " %")
                    Me.imgPcia3.ToolTip = sb3.ToString
                End If

                Rs.MoveNext()
            Else
            End If
        Next i







    End Sub
End Class